package cn.yangliu.nacos.management.handler;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import cn.yangliu.nacos.comm.model.Oauth2UserModel;
import cn.yangliu.nacos.comm.tools.SecurityUtils;
import cn.yangliu.operation.OperationHandler;
import cn.yangliu.operation.entity.Operator;
import org.springframework.stereotype.Component;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-04
 */
@Component
public class ManageOperationHandler implements OperationHandler {

    /**
     * Hunt operator operator.
     *
     * @param request the request
     * @return the operator
     */
    @Override
    public Operator huntOperator(HttpServletRequest request) {
        Oauth2UserModel currentUser = SecurityUtils.getCurrentUser();
        return new Operator() {
            @Override
            public String getOperatorName() {
                return currentUser.getUsername();
            }

            @Override
            public Serializable getOperatorId() {
                return currentUser.getId();
            }
        };
    }
}
